package com.czmh.etc.onlinepubsys.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.czmh.etc.common.core.annotation.ApiVersion;
import com.czmh.etc.onlinepubsys.json.JsonResult;
import com.czmh.etc.onlinepubsys.services.QrCodePromoterService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import me.chanjar.weixin.common.error.WxErrorException;

/**
 * @ClassName：QrCodePromoterController
 * @Description：二维码推广控制器
 * @Author： sevenchen.
 * @Date：2019-11-13 15:38:32
 * @Version：1.0.0
 */
@RestController
@RequestMapping("/{version}/api/qrcode/")
@Api(tags = "二维码推广控制器 - 【推广员与二维码相关控制】")
public class QrCodePromoterController {
    @Autowired
    private QrCodePromoterService qrCodePromoterService;

    @ApiVersion(1)
    @GetMapping(value = "createQrcode/{userId}/{mblNo}")
    @ApiOperation(value="生成厂家一级推广码", notes = "生成厂家一级推广码")
    public JsonResult createQrcode(@PathVariable String userId, @PathVariable String mblNo) throws WxErrorException{
        return qrCodePromoterService.createQrcode(userId, mblNo);
    }
    
    @ApiVersion(1)
    @GetMapping(value = "/{userId}")
    @ApiOperation(value="获取推广码", notes = "获取推广码")
    public JsonResult qrCode(@PathVariable String userId) throws WxErrorException{
        return qrCodePromoterService.qrCode(userId);
    }
}
